﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;
using WXYW.DAL;

namespace WXYW
{
    public partial class EditRole : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                UserService userService = new UserService();
                UserType role = userService.GetUserTypeByID(Convert.ToInt32(Request.QueryString[Constants.QUERYSTR_ROLE_ID]));
                roleNameTxtBox.Text = role.Name;
                roleDescription.Text = role.Description;
            }
        }

        protected void saveLnk_Click(object sender, EventArgs e)
        {
            UserService userService = new UserService();
            UserType role = userService.GetUserTypeByID(Convert.ToInt32(Request.QueryString[Constants.QUERYSTR_ROLE_ID]));
            role.Name = roleNameTxtBox.Text;
            role.Description = roleDescription.Text;
            RoleService roleService = new RoleService();
            roleService.UpdateRole(role);
            Response.Write(string.Format("<script language='JavaScript'> alert( '角色信息已被成功保存！');location.href= 'ManageRole.aspx' </script> ")); 
        }
    }
}
